this.name					= "bigShips_populator";
this.author					= "Thargoid & Eric Walch";
this.copyright				= "Creative Commons: attribution, non-commercial, sharealike.";
this.description				= "Populator for generic big ships facilitator OXP.";
this.version				= "1.0.2";

/*The main reason for using this generic populator instead of a custom one is to avoid overpopulation of a system. When every oxp with bigTraders would use its own addition script, it would mean that if you have 10 of such oxp's installed, you would also see 10 times as much of those ships in the system. With this generic populator you just get more variation when adding more oxp's with such big traders.

For programmers only:
To check in JS if the populator is loaded, use if(worldScripts["bigShips_populator"]) , which will be true if it is present. This way your script knows if the player has installed the oxp. If not, you can act upon it. e.g. by giving a warning or do the population by yourself. */

this.startUp = this.reset = function()
	{
	this.firstLaunch = false;
	}

this.shipWillExitWitchspace = function()
	{
	if(!system.isInterstellarSpace)
		{
		this.populator();
		}
	}

this.shipWillLaunchFromStation = function(station)
	{
	if(!this.firstLaunch)
		{
		this.populator();
		}
	}

this.populator = function()
	{
	this.firstLaunch = true;
	if(system.isInterstellarSpace || system.sun.isGoingNova || system.sun.hasGoneNova) 
		{ // stop the script if interstellar space, or system is going nova or indeed if it has gone nova already.
		return;
		}
	var productivity = system.productivity;
	var radius = system.mainPlanet.radius;
	var bigTraderCount = 0
	for(var loopCount = 0; loopCount < 5; loopCount++)
		{
		if(productivity > ((Math.random() * 56320) + (bigTraderCount * 5000)) && radius > Math.random() * 70E3)  // 56320 is maximum posible value of productivity.
			{
			system.legacy_addShipsWithinRadius("bigTrader", 1, "pwu", [0, 0, (Math.random() * 0.7) + 0.2], radius*0.5);
			++bigTraderCount
			}
		}
	log(this.name, bigTraderCount + " big trader(s) added to the " + system.name + " system.");
	}